;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (wigust packages logging)
  #:use-module (gnu packages logging)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix utils)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system go)
  #:use-module (guix build-system trivial)
  #:use-module (gnu packages)
  #:use-module (gnu packages ncurses)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages python)
  #:use-module (gnu packages python-web)
  #:use-module (gnu packages autotools))

#;(define-public beats
  (package
    (name "beats")
    (version "6.3.2")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/elastic/beats/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1vfijl7ij5wqx424nn0s4nspgikryd0sqa59bpvq1dsa67gidc9f"))))
    (build-system trivial-build-system)
    (arguments '(#:builder (begin (mkdir %output) #t)))
    (home-page "https://www.elastic.co/products/beats")
    (synopsis "Platform for single-purpose data shippers")
    (description "Beats is the platform for single-purpose data shippers.
They install as lightweight agents and send data from hundreds or thousands of
machines to Logstash or Elasticsearch.")
    (license #f)))

(define-public beats
  (package
    (name "beats")
    (version "6.3.2")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/elastic/beats/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1vfijl7ij5wqx424nn0s4nspgikryd0sqa59bpvq1dsa67gidc9f"))))
    (build-system gnu-build-system)
    (arguments '(#:phases (modify-phases %standard-phases
                            (delete 'configure))))
    (inputs
     `(("python" ,python)))
    (home-page "https://www.elastic.co/products/beats")
    (synopsis "Platform for single-purpose data shippers")
    (description "Beats is the platform for single-purpose data shippers.
They install as lightweight agents and send data from hundreds or thousands of
machines to Logstash or Elasticsearch.")
    (license #f)))

;; (define-public filebeat
;;   (package
;;     (name "filebeat")
;;     (version "6.3.2")
;;     (source (origin
;;               (method url-fetch)
;;               (uri (string-append "https://github.com/elastic/beats/archive/"
;;                                   "v" version ".tar.gz"))
;;               (file-name (string-append "beats" "-" version ".tar.gz"))
;;               (sha256
;;                (base32
;;                 "1vfijl7ij5wqx424nn0s4nspgikryd0sqa59bpvq1dsa67gidc9f"))))
;;     (build-system go-build-system)
;;     (arguments
;;      `(#:import-path "github.com/elastic/beats"
;;        #:tests? #f
;;        ;; We don't need to install the source code for end-user applications.
;;        #:install-source? #f
;;        #:phases
;;        (modify-phases %standard-phases
;;          (replace 'build
;;            (lambda _
;;              (with-directory-excursion "src/github.com/elastic/beats/beats-6.3.2/filebeat"
;;                (pk (getcwd))
;;                (invoke "go" "run" "magefile.go")))))))
;;     (home-page "https://www.elastic.co/products/beats")
;;     (synopsis "Platform for single-purpose data shippers")
;;     (description "Beats is the platform for single-purpose data shippers.
;; They install as lightweight agents and send data from hundreds or thousands of
;; machines to Logstash or Elasticsearch.")
;;     (license #f)))

#;(define-public filebeat
  (package
    (inherit beats)
    (name "filebeat")
    (build-system go-build-system)
    (arguments
     `(#:import-path "github.com/elastic/beats"
       #:tests? #f
       ;; We don't need to install the source code for end-user applications.
       #:install-source? #f
       #:phases
       (modify-phases %standard-phases
         (replace 'build
           (lambda _
             (with-directory-excursion (string-append
                                        "src/github.com/elastic/beats-"
                                        ,version)
               (invoke "go" "run" "magefile.go")))))))
    (home-page "https://www.elastic.co/products/beats/filebeat")
    (synopsis "Lightweight shipper for logs")
    (description "Filebeat helps you keep the simple things simple by offering
a lightweight way to forward and centralize logs and files.")
    (license license:asl2.0)))
